/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var maxDepth = function (root) {
  const getHeight = (root) => {
    let heightL = 0, heightR = 0
    if (root == null) return 0
    heightL = getHeight(root.left)
    heightR = getHeight(root.right)
    return heightL > heightR ? heightL + 1 : heightR + 1
  }
  return getHeight(root)
}
/**
 * 还可以用队列
 */